#################################################################
# @Description: 用例名称：容器镜像和存储管理，测试目的：支持容器镜像导入，验证import命令导入镜像
# @Date : 2023-11-25
# @Last Modified by :
# @Last Modified time:
#################################################################
#! /bin/bash
set -euo pipefail
res=0

# 前置条件
# 1.安装docker
# 2.拷贝镜像文件
yum install docker -y 1>/dev/null
docker_stat=`systemctl is-active docker` 
[ "$docker_stat" = "inactive" ] && systemctl restart docker

# 1.导入下载的镜像 
echo "------导入下载的镜像------"
docker import busybox.tar.xz busybox:latest || res=1
# 2.查看导入的镜像 
echo "------查看导入的镜像------"
docker images |grep busybox || res=1

# 判断用例执行是否成功
[ "$res" = "0" ] && echo -e "\033[32m-----------------test PASSED----------------\033[0m" || echo -e "\033[31m-----------------test FAILD----------------\033[0m"

# 后处理
docker rmi busybox:latest 1>/dev/null